#pragma once
// MESSAGE KF_P0Q PACKING

#define MAVLINK_MSG_ID_KF_P0Q 28

MAVPACKED(
typedef struct __mavlink_kf_p0q_t {
 float P0[30]; /*<  P0*/
 float Q[30]; /*<  Q*/
}) mavlink_kf_p0q_t;

#define MAVLINK_MSG_ID_KF_P0Q_LEN 240
#define MAVLINK_MSG_ID_KF_P0Q_MIN_LEN 240
#define MAVLINK_MSG_ID_28_LEN 240
#define MAVLINK_MSG_ID_28_MIN_LEN 240

#define MAVLINK_MSG_ID_KF_P0Q_CRC 126
#define MAVLINK_MSG_ID_28_CRC 126

#define MAVLINK_MSG_KF_P0Q_FIELD_P0_LEN 30
#define MAVLINK_MSG_KF_P0Q_FIELD_Q_LEN 30

#if MAVLINK_COMMAND_24BIT
#define MAVLINK_MESSAGE_INFO_KF_P0Q { \
    28, \
    "KF_P0Q", \
    2, \
    {  { "P0", NULL, MAVLINK_TYPE_FLOAT, 30, 0, offsetof(mavlink_kf_p0q_t, P0) }, \
         { "Q", NULL, MAVLINK_TYPE_FLOAT, 30, 120, offsetof(mavlink_kf_p0q_t, Q) }, \
         } \
}
#else
#define MAVLINK_MESSAGE_INFO_KF_P0Q { \
    "KF_P0Q", \
    2, \
    {  { "P0", NULL, MAVLINK_TYPE_FLOAT, 30, 0, offsetof(mavlink_kf_p0q_t, P0) }, \
         { "Q", NULL, MAVLINK_TYPE_FLOAT, 30, 120, offsetof(mavlink_kf_p0q_t, Q) }, \
         } \
}
#endif

/**
 * @brief Pack a kf_p0q message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 *
 * @param P0  P0
 * @param Q  Q
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_kf_p0q_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
                               const float *P0, const float *Q)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_KF_P0Q_LEN];

    _mav_put_float_array(buf, 0, P0, 30);
    _mav_put_float_array(buf, 120, Q, 30);
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_KF_P0Q_LEN);
#else
    mavlink_kf_p0q_t packet;

    mav_array_memcpy(packet.P0, P0, sizeof(float)*30);
    mav_array_memcpy(packet.Q, Q, sizeof(float)*30);
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_KF_P0Q_LEN);
#endif

    msg->msgid = MAVLINK_MSG_ID_KF_P0Q;
    return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_KF_P0Q_MIN_LEN, MAVLINK_MSG_ID_KF_P0Q_LEN, MAVLINK_MSG_ID_KF_P0Q_CRC);
}

/**
 * @brief Pack a kf_p0q message on a channel
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message will be sent over
 * @param msg The MAVLink message to compress the data into
 * @param P0  P0
 * @param Q  Q
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_kf_p0q_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
                               mavlink_message_t* msg,
                                   const float *P0,const float *Q)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_KF_P0Q_LEN];

    _mav_put_float_array(buf, 0, P0, 30);
    _mav_put_float_array(buf, 120, Q, 30);
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_KF_P0Q_LEN);
#else
    mavlink_kf_p0q_t packet;

    mav_array_memcpy(packet.P0, P0, sizeof(float)*30);
    mav_array_memcpy(packet.Q, Q, sizeof(float)*30);
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_KF_P0Q_LEN);
#endif

    msg->msgid = MAVLINK_MSG_ID_KF_P0Q;
    return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_KF_P0Q_MIN_LEN, MAVLINK_MSG_ID_KF_P0Q_LEN, MAVLINK_MSG_ID_KF_P0Q_CRC);
}

/**
 * @brief Encode a kf_p0q struct
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 * @param kf_p0q C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_kf_p0q_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_kf_p0q_t* kf_p0q)
{
    return mavlink_msg_kf_p0q_pack(system_id, component_id, msg, kf_p0q->P0, kf_p0q->Q);
}

/**
 * @brief Encode a kf_p0q struct on a channel
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message will be sent over
 * @param msg The MAVLink message to compress the data into
 * @param kf_p0q C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_kf_p0q_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_kf_p0q_t* kf_p0q)
{
    return mavlink_msg_kf_p0q_pack_chan(system_id, component_id, chan, msg, kf_p0q->P0, kf_p0q->Q);
}

/**
 * @brief Send a kf_p0q message
 * @param chan MAVLink channel to send the message
 *
 * @param P0  P0
 * @param Q  Q
 */
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

static inline void mavlink_msg_kf_p0q_send(mavlink_channel_t chan, const float *P0, const float *Q)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_KF_P0Q_LEN];

    _mav_put_float_array(buf, 0, P0, 30);
    _mav_put_float_array(buf, 120, Q, 30);
    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_KF_P0Q, buf, MAVLINK_MSG_ID_KF_P0Q_MIN_LEN, MAVLINK_MSG_ID_KF_P0Q_LEN, MAVLINK_MSG_ID_KF_P0Q_CRC);
#else
    mavlink_kf_p0q_t packet;

    mav_array_memcpy(packet.P0, P0, sizeof(float)*30);
    mav_array_memcpy(packet.Q, Q, sizeof(float)*30);
    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_KF_P0Q, (const char *)&packet, MAVLINK_MSG_ID_KF_P0Q_MIN_LEN, MAVLINK_MSG_ID_KF_P0Q_LEN, MAVLINK_MSG_ID_KF_P0Q_CRC);
#endif
}

/**
 * @brief Send a kf_p0q message
 * @param chan MAVLink channel to send the message
 * @param struct The MAVLink struct to serialize
 */
static inline void mavlink_msg_kf_p0q_send_struct(mavlink_channel_t chan, const mavlink_kf_p0q_t* kf_p0q)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    mavlink_msg_kf_p0q_send(chan, kf_p0q->P0, kf_p0q->Q);
#else
    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_KF_P0Q, (const char *)kf_p0q, MAVLINK_MSG_ID_KF_P0Q_MIN_LEN, MAVLINK_MSG_ID_KF_P0Q_LEN, MAVLINK_MSG_ID_KF_P0Q_CRC);
#endif
}

#if MAVLINK_MSG_ID_KF_P0Q_LEN <= MAVLINK_MAX_PAYLOAD_LEN
/*
  This varient of _send() can be used to save stack space by re-using
  memory from the receive buffer.  The caller provides a
  mavlink_message_t which is the size of a full mavlink message. This
  is usually the receive buffer for the channel, and allows a reply to an
  incoming message with minimum stack space usage.
 */
static inline void mavlink_msg_kf_p0q_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan,  const float *P0, const float *Q)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char *buf = (char *)msgbuf;

    _mav_put_float_array(buf, 0, P0, 30);
    _mav_put_float_array(buf, 120, Q, 30);
    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_KF_P0Q, buf, MAVLINK_MSG_ID_KF_P0Q_MIN_LEN, MAVLINK_MSG_ID_KF_P0Q_LEN, MAVLINK_MSG_ID_KF_P0Q_CRC);
#else
    mavlink_kf_p0q_t *packet = (mavlink_kf_p0q_t *)msgbuf;

    mav_array_memcpy(packet->P0, P0, sizeof(float)*30);
    mav_array_memcpy(packet->Q, Q, sizeof(float)*30);
    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_KF_P0Q, (const char *)packet, MAVLINK_MSG_ID_KF_P0Q_MIN_LEN, MAVLINK_MSG_ID_KF_P0Q_LEN, MAVLINK_MSG_ID_KF_P0Q_CRC);
#endif
}
#endif

#endif

// MESSAGE KF_P0Q UNPACKING


/**
 * @brief Get field P0 from kf_p0q message
 *
 * @return  P0
 */
static inline uint16_t mavlink_msg_kf_p0q_get_P0(const mavlink_message_t* msg, float *P0)
{
    return _MAV_RETURN_float_array(msg, P0, 30,  0);
}

/**
 * @brief Get field Q from kf_p0q message
 *
 * @return  Q
 */
static inline uint16_t mavlink_msg_kf_p0q_get_Q(const mavlink_message_t* msg, float *Q)
{
    return _MAV_RETURN_float_array(msg, Q, 30,  120);
}

/**
 * @brief Decode a kf_p0q message into a struct
 *
 * @param msg The message to decode
 * @param kf_p0q C-struct to decode the message contents into
 */
static inline void mavlink_msg_kf_p0q_decode(const mavlink_message_t* msg, mavlink_kf_p0q_t* kf_p0q)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    mavlink_msg_kf_p0q_get_P0(msg, kf_p0q->P0);
    mavlink_msg_kf_p0q_get_Q(msg, kf_p0q->Q);
#else
        uint8_t len = msg->len < MAVLINK_MSG_ID_KF_P0Q_LEN? msg->len : MAVLINK_MSG_ID_KF_P0Q_LEN;
        memset(kf_p0q, 0, MAVLINK_MSG_ID_KF_P0Q_LEN);
    memcpy(kf_p0q, _MAV_PAYLOAD(msg), len);
#endif
}
